{extend name="public/base" /}

<!--尾部-->

<!--返回顶部-->
{block name="content"}
{__block__}
<input type="hidden" name="mun_url" id="mun_url" value="2,1"/>
<style>
	.c-r .label-3 .Tab table td button{margin:3px 5px 3px 0;}
	.icon{border-radius:4px ;cursor: pointer;padding: 3px 9px;text-indent: -999999999px;}
	.icon_up{background: url("../../static/home/img/icon_ups.png") no-repeat center;background-size:20px 15px;
			background-color: #39f;}
	.icon_buttom{background: url("../../static/home/img/icon_buttom.png") no-repeat center;background-size:20px 15px;
			background-color: #39f;}	
	.icon_up2{background: url("../../static/home/img/icon_up2.png") no-repeat center;background-size:20px 15px;
			background-color: #39f;}
	.icon_buttom2{background: url("../../static/home/img/icon_buttom2.png") no-repeat center;background-size:20px 15px;
			background-color: #39f;}					
</style>
<div class="c-r right">
	<div class="label1">
		<div class="title">
			信息展示管理
		</div>
		<div class="label-3 label">
			<div class="search">
				<div class="">
					<input type="text" name="" id="" value="" placeholder="信息展示名称"/><button id="search_name"><i></i><span>搜信息展示</span></button>
				</div>
			</div>
			<div class="Statistics">
				<button class="blue"><a href="add">添加信息展示</a></button>

				<div class="" style="display: inline-block;margin-left: 46px">
					<div class="bor bor2 bor6 bor_two">
						<span>请选择</span><i></i>
						<ul style="display: none;">

						</ul>
					</div>
					<div class="bor bor2 bor7 bor_two">
						<span>请选择</span><i></i>
						<ul style="display: none;">

						</ul>
					</div>
					<div class="bor bor2 bor8 bor_two">
						<span>请选择</span><i></i>
						<ul style="display: none;">

						</ul>
					</div>
					<button class="blue" id="search">搜索</button>
				</div>
				<div class="clear"></div>
			</div>

			<div class="Tab Tabs">
				<table border="0" cellspacing="0" cellpadding="0" style="width: 984px;">
					<tr>
						<th style="width: 40px;"><input type="checkbox" name="" id="" value="" /></th>
						<th style="width: 60px;">ID</th>
						<th style="width: 80px; ">信息展示名</th>
						<th style="width: 100px;">分类1</th>
						<th style="width: 100px;">分类2</th>
						<th style="width: 100px;">分类3</th>
						<th style="width: 150px">内容</th>
						<th style="width: 180px;">操作</th>
					</tr>
				</table>
				<table border="0" cellspacing="0" cellpadding="0" style="width: 984px;">
					{foreach name="data" item="vo"}
					<tr>
						<td style="width: 40px;"><input type="checkbox" name="" id="" value="" /></td>
						<td style="width: 60px;" class="goodsid" id="goodsid">{$vo.id}</td>
						<td style="width: 80px;">{$vo.name}</td>
						<td style="width: 100px;" class="align-r">{$vo.menu1}</td>
						<td style="width: 100px;" class="align-r">{$vo.menu2}</td>
						<td style="width: 100px;" class="align-r">{$vo.menu3}</td>
						<td style="width: 150px;text-align: left;" class="align-r">{$vo.content}...</td>
						<td style="width: 180px;" class="align-r">
							<button onclick="compile('edit?id={$vo.id}')" class="modifybtn ml">编辑</button>
							<button style="background-color: red;border:red;" onclick="compile('del?id={$vo.id}')" class="modifybtn ml">删除</button>
						</tr>
					{/foreach}
				</table>

			</div>
			<div style="text-align: center" class="pages">
				{$page->render()}
			</div>
		</div>
	</div>
</div>

<div id="wrap" class="wrap">
	<div class="wrap-body express">
		<div class="title">
			详情查看
		</div>
		<iframe src="show" style="height: 100%; width: 100%;"></iframe>
		<span class="close-wrap close-win">×</span>
		<div class="wrap-btn">
			<span class="close-btn close-win">取消</span>
			<span class="next-btn close-win">确认</span>
		</div>
	</div>
</div>

<script type="text/javascript">
	$(".open-win").click(function(){
		var dataurl = $(this).attr('data-type');
		$("iframe").attr('src',dataurl)
	})
	var Ptid_one = $("#class_one");   //获取每级id
	var Ptid_tow = $("#class_two");
	var Ptid_three = $("#class_three");
	var Level = "0";   //获取级别
	var datall = [];
	var ajaxurl = "__publicPath__/home/commtype/ajaxindex";
	var storage=window.localStorage;

	// 判断刷新localstorage
	let arr = window.location.href.split('/');
	let action = arr[arr.length-1].split('.')[0];
	if (action == 'index') {storage.datall = ''}

	if (window.localStorage) {
		if (storage.datall) {
			datall = JSON.parse(storage.datall);
			menu1f();
		}else{
			$.ajax({
				type:"get",
				url:ajaxurl,
				data: '',
				dataType: "json",
				success: function(data){
	            	storage["datall"] = JSON.stringify(data);
	            	datall = data;	
	            	menu1f();
				}
			});
		}
	}else{
		alert('浏览器不支持localstorage');
	}

	// 一级菜单首次刷新
	function menu1f(){
        let data = datall;
		var	are = '';
		for (var i = 0; i < data.length; i++){
			are += "<li data-type="+data[i].tid+">"+data[i].name+"</li>";
			
		}
		$(".bor6 ul").html('')
		$(".bor6 ul").append(are)

		$(".bor6").unbind('click').bind('click',function(){
			$(".bor7 ul li").remove()
		})
	}

	var Li;  				//一级索引
	var towLi;				//二级索引
	//二级分类
	$(document).on("click", ".bor6 ul li", function(){
		var index = $(this).index()
		console.log('-----')
		$(".bor7 ul li").remove()
		$(".bor7 span").text('请选择')
		$(".bor8 ul li").remove()
		$(".bor8 span").text('请选择')
		Li = $(this).index()
		var	are = '';
		let data = datall;

		for (towLi = 0; towLi < data[Li].sub.length; towLi++) {   //二级菜单
			are += "<li data-type="+data[Li].sub[towLi].ptid+">"+data[Li].sub[towLi].name+"</li>"
			Level = data[Li].sub[towLi].level
		}
		$(".bor7 ul").html('')
		$(".bor7 ul").append(are)

	})

	//三级分类
	$(document).on("click", ".bor7 ul li", function(){
		$(".bor8 span").text('请选择')
		var stowLi = $(this).index()
		var	are = '';
		let data  = datall;

		for (var i = 0; i < data[Li].sub[stowLi].sub.length; i++) {   //三级菜单
			//alert(data[Li].sub[stowLi].sub[i].title)
			are += "<li data-type="+data[Li].sub[stowLi].sub[i].ptid+">"+data[Li].sub[stowLi].sub[i].name+"</li>"
			Level = data[Li].sub[stowLi].sub[i].level
		}
		$(".bor8 ul").html('')
		$(".bor8 ul").append(are)

	})


	$("#search").click(function(){
		var pid_one = $(".bor6 span").attr('data-type');
		var pid_two = $(".bor7 span").attr('data-type');
		var pid_three = $(".bor8 span").attr('data-type');
		if(!pid_one) pid_one = '';
		if(!pid_two) pid_two = '';
		if(!pid_three) pid_three = '';
		window.location.href='articlesearch?pid_one='+pid_one+'&pid_two='+pid_two+'&pid_three='+pid_three;
	})

	$("#search_name").click(function(){
		var searchname = $(this).parent().find('input').val()
		// if (searchname == '' || searchname == undefined) {
		// } else{
			window.location.href='articleSearch?name='+searchname;
		// }

	})
</script>

{/block}

